from recruit.models import Enterprise
from rest_framework.serializers import ModelSerializer
from recruit.models import Enterprise,Recruit
from rest_framework.response import Response

class EnterpriseSimpleSerializer(ModelSerializer):
    """增加企业访问次数模块 模型类序列化器"""
    class Meta:
        model = Enterprise
        fields = ['id','visits']

class RecruitSimpleSerializeer(ModelSerializer):
    """增加职位访问次数模块 模型类序列化器"""
    class Meta:
        model = Recruit
        fields = ['id','visits']

    def put(self,request, id):
        re_visit = Recruit.objects.get(id=id)
        re_visit.visits += 1
        re_visit.save()

        return Response({'message': '更新成功', 'success': True})

